package com.grom.util;

import java.util.List;

import com.dispacher.context.ContextHolder;
import com.dispacher.context.RequestContext;
import com.dispacher.context.ResponseContext;
import com.grom.po.GcmsUser;
import com.grom.service.GcmsUserService;

public abstract class SecurityUtil {
	private static List<GcmsUser> userCash;

	public synchronized static List<GcmsUser> getAllUser() {
		if (userCash == null) {
			userCash = GcmsUserService.instance.getAllUser();
		}
		return GcmsUserService.instance.getAllUser();
	}

	public boolean everLogin() {
		return false;
	}

	public static boolean isUserHasRight(String userID) {
		Object curUser = RequestContext.getCurSession().getAttribute(Constants.KEY_USER_SESSION);
		if (ContextHolder.getCurSession().getAttribute("USER").equals("ADMIN")) {
			return true;
		}
		if (curUser == null || !((GcmsUser) curUser).getID().equals(userID)) {
			return false;
		}
		return true;
	}
}
